<script src="/js/userProfile.js"></script>
<div class="user_head_info">
    <div class="user_ava"> 
        <?php if($user['avatar']) : ?>
        <img src="/images/uploads/userAvatars/<?php echo $user['avatar']; ?>" style="width:30px; height: 30px;"/>
        <?php else : ?>
        <img src="/images/prettyImg/default-avatarl.jpg" width="45px" alt="" />
        <?php endif; ?>
    </div>    
    <span class="profile_username"><?php echo $user['displayName']; ?></span><br/>
   <span class="last_login">Последний раз был   <?php echo Yii::app()->dateFormatter->format("dd MMMM в HH:mm", Yii::app()->user->getState('logDate')); ?></span> 
  
</div>


<?php $this->renderPartial('//partials/userMenu', array('userName'=>$user['login'], 'countNewComments'=>$this->countNewComments['count'], 'countNewMessages'=>$this->countNewMessages['count'],'curent'=>'profile')); ?>

<div class="padding40">

    
<div class="row">
        
    <div class="span6">
        <h2 class="profil_h2">О себе</h2>
        <div class="profil_fill">
        <span>Дата регистрации</span> <br/> 
        <?php echo Yii::app()->dateFormatter->format("dd MMMM yyyy года", $user['regDate']); ?>
        </div>  
        <div class="profil_fill">
        <span>Общая информация</span> <br/> 
        <?php echo $user['descr']; ?>
        </div> 
        
        <div class="profil_fill">
        <span>Ссылки</span> <br/> 
        <div class="pull-left left_block">
         <ul class="unstyled">
         <li>Скайп</li>    
         <li>Твиттер</li>    
         <li>Сайт</li>    
         </ul>    
        </div>   
        <div class="pull-left ">
         <ul class="links unstyled" >
         <li class="skype"> 
         <?php if(!empty($user['skype'])) :?>
          <a href="skype:<?php echo $user['skype']; ?>"> <?php echo $user['skype']; ?></a>
         <?php endif;  ?>
         </li>    
         <li>
             <?php if(!empty($user['twitter'])) : ?>
                <a href="http://twitter.com/#!/<?php echo $user['twitter']; ?>"><?php echo $user['twitter']; ?></a>
             <?php endif; ?></li>    
         <li> 
             <?php if(!empty($user['site'])) : ?>
            <noindex> <a rel="noffolow" href="<?php echo $user['site']; ?>"><?php echo $user['site']; ?></a></noindex>
                <?php endif; ?>
         </li>    
         </ul>    
        </div>  
        </div> 
        
       
       
    </div>
<div class="span6">
         <h2 class="profil_h2">Партнерки</h2>
         <div class="profil_fill">
        <span>Учасник</span> <br/> 
       <?php if(!empty($workPart)) : ?>
            <?php $count=count($workPart); $i = 0; ?>
            <?php foreach ($workPart as $item) : ?>
                <?php $paramArr = $item['parentId'] ? array('parentId'=>$item['parentId'], 'catId'=>$item['catId'], 'partnerUrl'=>$item['url']) : array('catId'=>$item['catId'], 'partnerUrl'=>$item['url']); ?>
                <a href="<?php  echo Yii::app()->createUrl('partner/profile/index', $paramArr); ?>"><?php echo $item['partnerName']; ?></a>
               <?php   $i++; if($i != $count) echo(',&nbsp;');  ?>
            <?php endforeach; ?>
        <?php else : ?>
            Я пока не выбрал партнерки с которыми я работаю.
        <?php endif; ?>
        </div> 
         <div class="profil_fill">
        <span>Представитель</span> <br/> 
       <?php if(!empty($delegatePart)) : ?>
        <?php $count=count($workPart); $i = 0; ?>
                <?php foreach ($delegatePart as $item) : ?>
                <?php $paramArr = $item['parentId'] ? array('parentId'=>$item['parentId'], 'catId'=>$item['catId'], 'partnerUrl'=>$item['url']) : array('catId'=>$item['catId'], 'partnerUrl'=>$item['url']); ?>
                <a href="<?php  echo Yii::app()->createUrl('partner/profile/index', $paramArr); ?>"><?php echo $item['name']; ?></a>
                   <?php   $i++; if($i != $count && $count!=1) echo(',&nbsp;');  ?>
                    <?php endforeach; ?>
        <?php else : ?>
            Я не представляю ни одной партнерской программы.   
        <?php endif; ?>
        </div> 
        
        
    </div>
</div>
</div>
<hr/>
<div class="padding40">
    <h2 class="profil_h2">Свежие отзывы <?php echo !empty($countData['reviews']['count']) ? '<span class="profil_count">'.$countData['reviews']['count'].'</span>' : '' ; ?></h2>    

    <?php if(!empty($reviews)) : ?>
        <?php for($i=0, $j=0; $i<count($reviews); $i++, $j++) : ?>
 
            <?php $paramsArr = array('url'=>$reviews[$i]['url'], 'partnerUrl'=>$reviews[$i]['partnerUrl'], 'catId'=>$reviews[$i]['catId']) ; ?>

           

            <?php if($reviews[$i]['status'] == 'Сомнительный') : ?>
               <span class="bad_rewievs pull-right"><a href="<?php echo $this->options[3]['val']; ?>">Сомнительный отзыв</a></span>
            <?php endif; ?>
                
            <div class="profil_review_header"><span class="dark"><?php echo $reviews[$i]['name'].'</span> | '.$reviews[$i]['catName']; ?> 
            
            <?php if(!empty($reviews[$i]['subCats'])) : ?>
                    &nbsp;&nbsp;
                    
                   <ul  class="inline unstyled profile_subcats">
               
                <?php for($l=0; $l<count($reviews[$i]['subCats']); $l++) : ?>
                   <li class="subcats<?php echo $l;  ?>">
                        <a href="<?php echo Yii::app()->createUrl('partner/default/cat', array('catId'=>$reviews[$i]['subCats'][$l]['catId'], 'parentId'=>$reviews[$i]['subCats'][$l]['parentId'])); ?>"> <?php echo $reviews[$i]['subCats'][$l]['name']; ?> </a>
                    </li>&nbsp;&nbsp;
                <?php endfor; ?>
                     </ul>
            <?php endif; ?>    
            </div>
            <div class="reviews_cut"></div>
            <?php 
                if($reviews[$i]['averageRating'] < 5) $color = 'red';
                else if($reviews[$i]['averageRating'] < 8) $color = 'gray';
                else $color = '#E3F4CD';
            ?>
            <div class="profil_reviews" >
                <div class="reviews_date"><?php echo Yii::app()->dateFormatter->format("dd MMMM yyyy", $reviews[$i]['date']); ?></div>
                
                <?php if(!empty($reviews[$i]['title'])) : ?>
                    <a class="head" href="<?php echo Yii::app()->createUrl('partner/profile/review', $paramsArr);?>"><?php echo CPartnerkiHelper::getShortText($reviews[$i]['title'], 80);?></a>
                <?php else : ?>
                    <a  class="head"href="<?php echo Yii::app()->createUrl('partner/profile/review', $paramsArr);?>">...</a>
                <?php endif; ?>
               <div class="short_text">     
                <script LANGUAGE="JavaScript">document.write('<?php echo CPartnerkiHelper::getShortText($reviews[$i]['text'], 250); ?>');</script>     
               </div>
                <a href="<?php echo Yii::app()->createUrl('partner/profile/review', $paramsArr);?>">Читать дальше</a>&nbsp;
                <?php if($reviews[$i]['countComments']) : ?>
                    <?php echo $reviews[$i]['countComments']; ?> 
                    <?php if(!empty($reviews[$i]['countNewCom']) && $reviews[$i]['countNewCom']) : ?>
                        <span class="comments_green">
                            + <?php echo $reviews[$i]['countNewCom']; ?> 
                        </span>
                    <?php endif; ?>    
                    коментари<?php echo CPartnerkiHelper::getEndCom(!empty($reviews[$i]['countNewCom']) && $reviews[$i]['countNewCom'] ? $reviews[$i]['countNewCom'] : $reviews[$i]['countComments']); ?>
                <?php else : ?>    
                    коментариев нет
                <?php endif; ?>
            </div> 
        <?php endfor; ?>
    <?php else : ?>
        Пользователь пока не оставил ни одного отзыва
    <?php endif; ?>
        <a class="profil_all_links" href="<?php echo Yii::app()->createUrl('user/profile/reviews', array('login'=>$user['login'])); ?>">Все отзывы</a>
  </div>
<hr/>
        <div class="padding40">
        
        
        <h2 class="profil_h2">Свежие коментарии <?php echo !empty($countData['revComments']['count']) ? '<span class="profil_count">'.$countData['revComments']['count'].'</span>' : ''; ?></h2> 
   

    <?php if(!empty($revComments)) : ?>
        <?php for($i=0, $j=0; $i<count($revComments); $i++, $j++) : ?>
        
            <?php $paramsArr = array('url'=>$revComments[$i]['url'], 'partnerUrl'=>$revComments[$i]['partnerUrl'], 'catId'=>$revComments[$i]['catId']) ; ?>
          
            <div class="profil_review_header"><span class="dark"> <?php echo $revComments[$i]['catName'].'</span> | '.$revComments[$i]['name']; ?>

            <?php if(!empty($revComments[$i]['subCats'])) : ?>
                      <ul  class="inline unstyled profile_subcats">
                <?php for($l=0; $l<count($revComments[$i]['subCats']); $l++) : ?>
                     <li class="subcats<?php echo $l;  ?>">
                        <a href="<?php echo Yii::app()->createUrl('partner/default/cat', array('catId'=>$revComments[$i]['subCats'][$l]['catId'], 'parentId'=>$revComments[$i]['subCats'][$l]['parentId'])); ?>"> <?php echo $revComments[$i]['subCats'][$l]['name']; ?> </a>
                  </li>&nbsp;&nbsp;
                <?php endfor; ?>
                      </ul>  
            <?php endif; ?> 
            </div>
            <div class="last_comment">
                 <?php if(!empty($revComments[$i]['title'])) : ?>
                <a class="head" href="<?php echo Yii::app()->createUrl('partner/profile/review', $paramsArr).'#comment'.$revComments[$i]['comId'];?>"><?php echo   CPartnerkiHelper::getShortText($revComments[$i]['title'], 80); ?></a>
                <?php else : ?>
                    <a class="head" href="<?php echo Yii::app()->createUrl('partner/profile/review', $paramsArr);?>">...</a>
                <?php endif; ?>
                <div class="short_conmment">    
                <div class="reviews_date"> <?php echo Yii::app()->dateFormatter->format("dd MMMM yyyy ", $revComments[$i]['date']); ?></div>
                <?php  echo CPartnerkiHelper::getShortText($revComments[$i]['text'], 250); ?>
                </div>
            </div>             
        <?php endfor; ?>
    <?php else : ?>
        Пользователь пока не оставил ни одного комментария
    <?php endif; ?>
        <a class="profil_all_links"  href="<?php echo Yii::app()->createUrl('user/profile/comments', array('login'=>$user['login'])); ?>">Все коментарии</a>
        
        </div>
<hr/>
        <div class="padding40">
        
 <h2 class="profil_h2">Свежие сообщения на минифорумах<?php echo !empty($countData['messages']['count']) ? '<span class="profil_count">'.$countData['messages']['count'].'</span>' : ''; ?></h2> 

    <?php if(!empty($messages)) : ?>
        <?php for($i=0; $i<count($messages); $i++) : ?>
            <?php $paramsArr = array('url'=>$messages[$i]['url'], 'partnerUrl'=>$messages[$i]['partnerUrl'], 'catId'=>$messages[$i]['catId']) ; ?>
           <div class="profil_review_header"><span class="dark"> <?php echo $messages[$i]['catName'].'</span> | '.$messages[$i]['name']; ?> 
            
            <?php if(!empty($messages[$i]['subCats'])) : ?>
                          <ul  class="inline unstyled profile_subcats">
                <?php for($l=0; $l<count($messages[$i]['subCats']); $l++) : ?>
                     <li class="subcats<?php echo $l;  ?>">
                        <a href="<?php echo Yii::app()->createUrl('partner/default/cat', array('catId'=>$messages[$i]['subCats'][$l]['catId'], 'parentId'=>$messages[$i]['subCats'][$l]['parentId'])); ?>"> <?php echo $messages[$i]['subCats'][$l]['name']; ?> </a>
                    </li>&nbsp;&nbsp;
                <?php endfor; ?>
                    </ul>
            <?php endif; ?>
            </div>
          <div class="last_comment">
                <a  class="head" href="<?php echo Yii::app()->createUrl('partner/forum/theme', $paramsArr);?>">
                    <?php echo   CPartnerkiHelper::getShortText($messages[$i]['title'], 80); ?>
                </a>
                <?php if($messages[$i]['isFirst']) : ?>
                  <span style="background-color: #48ad43;margin-left: 5px; padding: 3px; color: #ffffff">Новая тема</span>
                <?php endif; ?>
                  <div class="short_conmment">    
                <div class="reviews_date">   
                <?php echo Yii::app()->dateFormatter->format("dd MMMM yyyy ", $messages[$i]['comDate']); ?></div>
                <?php $mes = preg_replace('/\[quote([\s\S]*)\[\/quote\]/', '', $messages[$i]['text']); ?>
              <?php echo CPartnerkiHelper::getShortText($mes, 250);  ?>
              </div>
            </div> 
       <?php endfor; ?>
    <?php else : ?>
        Пользователь пока не оставил ни одного сообщения на мини-форуме
    <?php endif; ?>
    <a class="profil_all_links" href="<?php echo Yii::app()->createUrl('user/profile/posts', array('login'=>$user['login'])); ?>">Все сообщения на минифорумах</a>
</div>